package com.ruoyi.project.configureSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.configureSystem.domain.VDatainfo;
import com.ruoyi.project.configureSystem.service.IVDatainfoService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 指标信息Controller
 * 
 * @author wangshuo
 * @date 2020-05-17
 */
@RestController
@RequestMapping("/configureSystem/vdatainfo")
public class VDatainfoController extends BaseController
{
    @Autowired
    private IVDatainfoService vDatainfoService;

    /**
     * 查询指标信息列表
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vdatainfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(VDatainfo vDatainfo)
    {
        startPage();
        List<VDatainfo> list = vDatainfoService.selectVDatainfoList(vDatainfo);
        return getDataTable(list);
    }

    /**
     * 导出指标信息列表
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vdatainfo:export')")
    @Log(title = "指标信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(VDatainfo vDatainfo)
    {
        List<VDatainfo> list = vDatainfoService.selectVDatainfoList(vDatainfo);
        ExcelUtil<VDatainfo> util = new ExcelUtil<VDatainfo>(VDatainfo.class);
        return util.exportExcel(list, "vdatainfo");
    }

    /**
     * 获取指标信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vdatainfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(vDatainfoService.selectVDatainfoById(id));
    }

    /**
     * 新增指标信息
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vdatainfo:add')")
    @Log(title = "指标信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VDatainfo vDatainfo)
    {
        return toAjax(vDatainfoService.insertVDatainfo(vDatainfo));
    }

    /**
     * 修改指标信息
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vdatainfo:edit')")
    @Log(title = "指标信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VDatainfo vDatainfo)
    {
        return toAjax(vDatainfoService.updateVDatainfo(vDatainfo));
    }

    /**
     * 删除指标信息
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:vdatainfo:remove')")
    @Log(title = "指标信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vDatainfoService.deleteVDatainfoByIds(ids));
    }


    /**
     * 获取站点下工艺类型，指标信息树
     */
    @GetMapping("/getDatainfoTreeByStationCode")
    public AjaxResult getDatainfoTreeByStationCode(String stationcode)
    {
        AjaxResult ajaxResult = new AjaxResult();
        List<VDatainfo> list = vDatainfoService.getDatainfoTreeByStationCode(stationcode);
        return AjaxResult.success(list);
    }
}
